Fix a bunch of cases where default features were incorrectly included#2012
Fix a bunch of cases where default features were incorrectly included#2012cqundefine wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes cases where default features were being incorrectly included, particularly around host dependencies (notably when cross-compiling with default features disabled). It updates dependency planning behavior and adds regression tests to ensure host/target default-feature metadata is handled as intended.
Changes:
- Prevents adding a default-feature reinstall requirement for non-user-requested clusters when the package isn’t installed.
- Adjusts versioned dependency graph handling so host dependencies don’t get implicit default features; default features for versioned plans are only emitted when enabled for the node.
- Adds new unit tests covering host dependency default-feature suppression in both classic and versioned planning.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vcpkg/dependencies.cpp | Fixes default-feature inclusion logic in both classic cluster reinstall handling and versioned dependency planning (esp. host deps). |
| src/vcpkg-test/plan.cpp | Adds tests asserting host-dependency default-feature metadata is suppressed appropriately in classic plans. |
| src/vcpkg-test/dependencies.cpp | Adds a versioned-plan test ensuring host dependencies respect explicit no-defaults. |
f3f6d11 to
f272979
Compare
f272979 to
c9b5533
Compare
c9b5533 to
a07cfe0
Compare
|
I would like to see the exact install command and problem before the change. |
|
(For such cases, I prefer to push tests first, to demonstrate the error in CI.) |
Right, so with this simple test package (just added it to the vcpkg repository for testing): {
"name": "testport",
"version": "0.0.0",
"description": "test",
"dependencies": [
{
"name": "testport",
"host": true,
"default-features": false
}
],
"default-features": [
"a"
],
"features": {
"a": {
"description": "a"
}
}
}Calling Running the same command with a binary built with those fixes it correctly skips adding the
Do you think that is something I should do now, like revert the fix, let the CI run and then readd the fix? |
This is not nice but expected, should've been |
|
Right, already works as intended by Microsoft. Cf. microsoft/vcpkg#51325 for a recent discussion. |
I really don't understand why this should be the "intended" behavior: If I don't want default features and the port doesn't need them, why would vcpkg decide otherwise for the host triplet? if a port depends on itself on the host triplet, I think disabling default features on the host as well doesn't break anything because the user clearly said "I don't want default features for this port". This is fundamentally different from saying "I do want feature X on the target triplet". IMO, disabling default features should extend to the host triplet, given the number of complaints about this. However, I do see that this would in general add the inconsistency of mirroring user settings between triplets. If I depend on a feature of port A, and port A has a dependency on itself, that feature would not be automatically added to the host triplet, so it makes sense that the same is true for requesting default features:
|
|
The current behavior is not an "accident", see #177 which proposes a similar design change as described in the PR description. It's true that default-features and host dependencies were designed in isolation and have created a situation that people seem unhappy with, but most of the heartburn there also applies to default features with non host dependencies.
If a port is not directly named by a user at the top level, it gets default features turned on. That is, given ports vcpkg install Binstalls The intended use case for default features are for cases like this. In The problem is that users expect and use default features as merely "if I didn't say features on the command line these are what I meant," rather than the libarchive example above. They want a command line convenience where |
In some cases related to host dependencies, default features were being included even those they were disabled, found this when cross compiling
qtbasewith default features disabled.